#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
//对于基类数据成员的隐藏
class Base{

public:
    long _data = 10;
};

class Derived : public Base{

public:
    

    long _data = 20;
    //string _data = "hello";
};

void test(){
    Derived d;
    cout << d._data << endl;// 20
    //如果此时希望访问基类的_data
    cout << d.Base::_data << endl;//不是很推荐
}

void test2(){
    cout << sizeof(Base) << endl;
    cout << sizeof(Derived) << endl;
    Derived d;
    Derived * p = &d;
    long * plong = (long *)p;
    cout << *plong << endl; //10
    cout << *(plong + 1) << endl;//20
}

int main()
{
    test2();
    return 0;
}

